using System;
using System.Drawing.Text;
using System.Windows.Forms;
using System.Drawing;
using System.Drawing.Drawing2D;

namespace FreeHTPC
{
	partial class MainWindow
	{
		private abstract class MenuBase
		{
			public abstract void Paint(object sender, PaintEventArgs e);
		}

		private MenuBase ActiveMenu = new MainVideoMenu();
		
		private class SimpleMenuItem
		{
			private string text;
			private bool enabled;
			private EventHandler handler;

			public SimpleMenuItem(string text, bool enabled, EventHandler handler)
			{
				this.text = text;
				this.enabled = enabled;
				this.handler = handler;
			}


			public string Text
			{
				get { return text; }
				set { text = value; }
			}

			public bool Enabled
			{
				get { return enabled; }
				set { enabled = value; }
			}

			public EventHandler Handler
			{
				get { return handler; }
				set { handler = value; }
			}
		}
		
		private abstract class SimpleMenuBase: MenuBase
		{
			protected abstract SimpleMenuItem[] Items
			{
				get;
			}
			
			private static readonly Font itemFont = new Font("Tahoma",38);
			private static readonly int itemHeight = 65;
			protected SimpleMenuItem activeItem;

			public override void Paint(object sender, PaintEventArgs e)
			{
				MainWindow w = (MainWindow) sender;
				Graphics g = e.Graphics;
				int size = itemHeight*Items.Length;
				int posTop = (w.Height - size)/2;
				g.TextRenderingHint = TextRenderingHint.SingleBitPerPixelGridFit;
				for(int i=0;i<Items.Length;++i)
				{
					int j = i + 1;
					if(j==10) j = 0;
					SimpleMenuItem item = Items[i];
					DrawStringWithGlow(g, "[" + j + "]    " + item.Text, itemFont, item==activeItem?Brushes.White:Brushes.Lime, Brushes.Black, 100, posTop + itemHeight * i);
				}
			}

		}
		
		private class MainVideoMenu: SimpleMenuBase
		{
			private SimpleMenuItem mi_OpenFile;
			private SimpleMenuItem mi_Navigate;
			private SimpleMenuItem mi_PanAndScan;
			private SimpleMenuItem mi_ffdShow;
			private SimpleMenuItem mi_Audio;
			private SimpleMenuItem mi_Subtitles;
			private SimpleMenuItem[] items;


			public MainVideoMenu()
			{
				mi_OpenFile = new SimpleMenuItem("Open File...",true,delegate(object sender, EventArgs e) {  });
				mi_Navigate = new SimpleMenuItem("GoTo...", true, delegate(object sender, EventArgs e) { });
				mi_PanAndScan = new SimpleMenuItem("Video Frame Settings...", true, delegate(object sender, EventArgs e) { });
				mi_ffdShow = new SimpleMenuItem("Image Properties...", true, delegate(object sender, EventArgs e) { });
				mi_Audio = new SimpleMenuItem("Audio...", true, delegate(object sender, EventArgs e) { });
				mi_Subtitles = new SimpleMenuItem("Subtitles...", true, delegate(object sender, EventArgs e) { });
				activeItem = mi_PanAndScan;
				items = new SimpleMenuItem[] { mi_OpenFile, mi_Navigate, mi_PanAndScan, mi_ffdShow, mi_Audio, mi_Subtitles };
			}

			protected override SimpleMenuItem[] Items
			{
				get { return items; }
			}
		}
		
		
		
	}
}